package com.whmskj.xjlhsc.mobie.ProductionManagement.mapper;

import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.entity.*;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EnergyConsumptionOfFineSandProductionMapper {
    List<EnergyConsumptionOfFineSandProductionVO> getEnergyConsumptionOfFineSandProduction(
            @Param("startDate") String startDate,
            @Param("endDate") String endDate);

    List<ShiftProductionEnergyVO> getShiftProductionEnergy(
            @Param("date") LocalDate date,
            @Param("DayShiftOrEveningShift") String DayShiftOrEveningShift);



    List<MonthlyVarietyDetailVO> getMonthlyVarietyStats(@Param("monthStart") String monthStart, @Param("monthEnd") String monthEnd);

    List<BanZu> getBanZus();

    ShiftDate getCrewDataJia(@Param("monthStr") String monthStr);

    ShiftDate getCrewDataYi(@Param("monthStr") String monthStr);

    ShiftDate getCrewDataBing(@Param("monthStr") String monthStr);

    @Select("SELECT CAST(COALESCE(SUM(b.actualyieldkg), 0) AS FLOAT) AS lateYield " +
            "FROM sb02EquipmentCounterAccount c " +
            "INNER JOIN shachang_sb_banyield b ON c.id = b.mesid " +
            "WHERE c.process = '细纱' " +
            "AND c.id IS NOT NULL " +
            "AND DATE(b.day) BETWEEN #{monthStart} AND #{monthEnd} " +
            "AND b.shift = '晚班'")
    Float getLateYield(@Param("monthStart") String monthStart, @Param("monthEnd") String monthEnd);

    @Select("SELECT CAST(COALESCE(CASE WHEN SUM(b.yieldkg) > 0 THEN (SUM(b.actualyieldkg) / SUM(b.yieldkg) * 100) ELSE 0 END, 0) AS FLOAT) AS lateEfficiency " +
            "FROM sb02EquipmentCounterAccount c " +
            "INNER JOIN shachang_sb_banyield b ON c.id = b.mesid " +
            "WHERE c.process = '细纱' " +
            "AND c.id IS NOT NULL " +
            "AND DATE(b.day) BETWEEN #{monthStart} AND #{monthEnd} " +
            "AND b.shift = '晚班'")
    Float getLateEfficiency(@Param("monthStart") String monthStart, @Param("monthEnd") String monthEnd);

    @Select("SELECT CAST(COALESCE(SUM(b.actualyieldkg), 0) AS FLOAT) AS lateYield " +
            "FROM sb02EquipmentCounterAccount c " +
            "INNER JOIN shachang_sb_banyield b ON c.id = b.mesid " +
            "WHERE c.process = '细纱' " +
            "AND c.id IS NOT NULL " +
            "AND DATE(b.day) BETWEEN #{monthStart} AND #{monthEnd} " +
            "AND b.shift = '早班'")
    Float getEarlyYield(@Param("monthStart") String monthStart, @Param("monthEnd") String monthEnd);

    @Select("SELECT CAST(COALESCE(CASE WHEN SUM(b.yieldkg) > 0 THEN (SUM(b.actualyieldkg) / SUM(b.yieldkg) * 100) ELSE 0 END, 0) AS FLOAT) AS lateEfficiency " +
            "FROM sb02EquipmentCounterAccount c " +
            "INNER JOIN shachang_sb_banyield b ON c.id = b.mesid " +
            "WHERE c.process = '细纱' " +
            "AND c.id IS NOT NULL " +
            "AND DATE(b.day) BETWEEN #{monthStart} AND #{monthEnd} " +
            "AND b.shift = '早班'")
    Float getEarlyEfficiency(@Param("monthStart") String monthStart, @Param("monthEnd") String monthEnd);

    List<MonthProductionList> getMonthList(@Param("month") String month);

    List<MonthEfficiencyList> getEfficiencyList(@Param("month") String month);

    ProdctionVO getProdctionVO(String month);

    List<ClassProductionVOListVO> getClassProductionVOListVO(String month);

    EfficiencyVOO getEfficiencyVOO(String month);

    ClassProductionDe getClassProduction(String month);

    List<ClassProduction> getClassProductionList(String month);

    List<EfficiencyListVOList> getEfficiencyListVOList(String month);
}
